using System;
using System.Collections.Generic;
using System.Text;
using BuildingBasicDomain;

using MVCFramework.Models;

namespace MVCFramework.Presenter.Commands
{
    internal class RemoveObjcetCommand<T> : Command where T : IModelData
    {

        private IModel _constraction;
        private IList<T> _objects;

        public RemoveObjcetCommand(IModel constraction, IList<T> elements)
        {
            this._constraction = constraction;
            this._objects = elements;
        }
        public RemoveObjcetCommand(IModel constraction, T element)
        {
            this._constraction = constraction;
            this._objects = new List<T>();
            this._objects.Add ( element);

        }

        public override bool Execute()
        {
            bool IsAdded = true;

            foreach (T _object in _objects)
                IsAdded = IsAdded && _constraction.RemoveObject(_object);
            return IsAdded;
        }
        public override bool  UnExecute()
        {
            bool IsAdded = true;
            foreach (T _object in _objects)
                IsAdded = IsAdded && _constraction.AddObject (_object);
            return IsAdded;
        }

        public override string Description
        {
            get
            {
                return "Object (s) Removed  from Models";
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }
    }
}
